/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package tienda;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Alumno
 */
public class Venta {
    private String numeric;
    private String fecha;
    private double descuento;
    private Cliente cliente;
    private List<LineaVenta> lineasVenta;

    public Venta(String numeric, String fecha, Cliente cliente) {
        this.numeric = numeric;
        this.fecha = fecha;
        this.cliente = cliente;
        this.descuento = 0.0;
        this.lineasVenta = new ArrayList();
    }

   public void agregarLineaVenta(int cantidad, Producto producto){
    LineaVenta lineaVenta = new LineaVenta(cantidad, producto);
    lineasVenta.add(lineaVenta);
    
}
   
   public int calcularTotal(){
       int total = 0;
       for(LineaVenta lineaVenta : lineasVenta){
           total += lineaVenta.calcularSubTotal();
           //total = total + lineaVenta.calcularSubTotal();
       }
       return total;
   }
   
   public double calcularDescuento(){
       if(calcularTotal()>100)
           return 20;
       else 
           return 0;
   }
   
  public double calcularMonto(){
      return calcularTotal() - calcularDescuento();
  }
}